/**************************************************************************//**
 *
 *  \copyright  This software is the property of  Technologies. Any
 *              information contained in this doc should not be reproduced,
 *              or used, or disclosed without the written authorization from
 *               Technologies.
 *
 *  \brief      This is the source file of the ram module.
 *
 *  \file       bl_ram.c
 *  \ingroup    ram_module
 *  \author     
 *
 *  \version    2.0.0
 *  \date       25/09/2012
 *
 *  \par        Changelist
 *      Version  | Date       | Authors    | CR# | Descriptions
 *      -------- | ---------- | ---------- | --- | ------------
 *      02.00.00 | 25/09/2012 | xin.shang  | N/A | Boot020001
 *
 *****************************************************************************/
#include "bl_common.h"
#include "bl_ram.h"

/*****************************************************************************
 *  QAC Suppression
 *****************************************************************************/
/*PRQA S 306,1532,3227 EOF*/
/*
 * MISRA-C:2004 11.3(306):Cast a pointer to an integral type.
 * To address a flash must cast an integral type to a pointer.
 *
 * 1532:The function is only referenced in one translation unit.
 * all functions in this file are configurations in the Security Module.
 *
 * 3227:The parameter is never modified and so it could be declared with const.
 *
 */
const unsigned char firmware[1452] = {
0x01,0x80,0x00,0x00,0x36,0x39,0x31,0x47,0x00,0x00,0x01,0x00,0x79,0x74,0x00,0x20,
0xBB,0x74,0x00,0x20,0x0B,0x75,0x00,0x20,0x41,0x75,0x00,0x20,0x65,0x75,0x00,0x20,
0x9E,0x49,0x0A,0x68,0x10,0x43,0x08,0x60,0x70,0x47,0x9C,0x49,0x0A,0x68,0x82,0x43,
0x0A,0x60,0x70,0x47,0x9A,0x49,0x0A,0x68,0x10,0x43,0x08,0x60,0x70,0x47,0x98,0x49,
0x0A,0x68,0x82,0x43,0x0A,0x60,0x70,0x47,0x42,0x69,0x96,0x4B,0x13,0x40,0x19,0x43,
0x41,0x61,0x70,0x47,0x41,0x69,0x01,0x22,0x91,0x43,0x41,0x61,0x41,0x69,0x02,0x22,
0x0A,0x43,0x42,0x61,0x70,0x47,0x41,0x69,0x02,0x22,0x91,0x43,0x41,0x61,0x41,0x69,
0x01,0x22,0x0A,0x43,0x42,0x61,0x70,0x47,0x81,0x61,0x70,0x47,0x00,0x21,0xC9,0x43,
0x81,0x61,0x70,0x47,0x01,0x6A,0xE0,0x20,0x00,0x03,0x08,0x40,0x70,0x47,0x00,0x6A,
0x81,0x0A,0x08,0x00,0xC0,0x07,0xC0,0x0F,0x70,0x47,0x80,0x21,0xC9,0x00,0x01,0x62,
0x70,0x47,0x00,0x6A,0x41,0x0A,0x08,0x00,0xC0,0x07,0xC0,0x0F,0x70,0x47,0x00,0x6A,
0x01,0x0A,0x08,0x00,0xC0,0x07,0xC0,0x0F,0x70,0x47,0x80,0x21,0x49,0x00,0x01,0x62,
0x70,0x47,0x00,0x6A,0x41,0x08,0x08,0x00,0xC0,0x07,0xC0,0x0F,0x70,0x47,0x02,0x21,
0x01,0x62,0x70,0x47,0x01,0x6A,0x08,0x00,0xC0,0x07,0xC0,0x0F,0x70,0x47,0x01,0x21,
0x01,0x62,0x70,0x47,0xFE,0xB5,0x00,0x24,0x02,0x94,0x01,0x22,0x6B,0x46,0x1A,0x70,
0xA3,0x4D,0xA8,0x42,0x00,0xD0,0xFE,0xE7,0x01,0x91,0x08,0x46,0x91,0x04,0x88,0x42,
0x00,0xD3,0xFE,0xE7,0x20,0x20,0xFF,0xF7,0x8B,0xFF,0x01,0x98,0x80,0x07,0x06,0xD1,
0x28,0x00,0xFF,0xF7,0xB7,0xFF,0x80,0x21,0x09,0x03,0x88,0x42,0x01,0xD1,0x20,0x46,
0xFE,0xBD,0xCF,0x02,0x38,0x00,0xFF,0xF7,0x85,0xFF,0x21,0x46,0x28,0x00,0xFF,0xF7,
0x8B,0xFF,0x28,0x00,0xFF,0xF7,0x97,0xFF,0xEF,0xF3,0x10,0x86,0x72,0xB6,0x91,0x49,
0x28,0x00,0xFF,0xF7,0x99,0xFF,0x90,0x49,0x28,0x00,0xFF,0xF7,0x95,0xFF,0x86,0xF3,
0x10,0x88,0x28,0x00,0xFF,0xF7,0xC3,0xFF,0x28,0x00,0xFF,0xF7,0xAE,0xFF,0x28,0x00,
0xFF,0xF7,0x9B,0xFF,0x89,0x48,0x01,0x99,0x08,0x60,0x02,0x9E,0x76,0x1C,0xA8,0x0B,
0x86,0x42,0x22,0xD2,0x28,0x00,0xFF,0xF7,0x9A,0xFF,0x00,0x28,0x1D,0xD1,0x28,0x00,
0xFF,0xF7,0x8F,0xFF,0x00,0x28,0x18,0xD1,0x28,0x00,0xFF,0xF7,0x80,0xFF,0x00,0x28,
0x13,0xD1,0x28,0x00,0xFF,0xF7,0x9E,0xFF,0x00,0x28,0xE7,0xD0,0x28,0x00,0xFF,0xF7,
0x9E,0xFF,0x28,0x00,0xFF,0xF7,0x6A,0xFF,0x38,0x00,0xFF,0xF7,0x48,0xFF,0x20,0x20,
0xFF,0xF7,0x3B,0xFF,0x68,0x46,0x00,0x78,0xFE,0xBD,0x68,0x46,0x04,0x70,0xF0,0xE7,
0xFE,0xB5,0x00,0x24,0x02,0x94,0x01,0x22,0x6B,0x46,0x1A,0x70,0x6C,0x4D,0xA8,0x42,
0x00,0xD0,0xFE,0xE7,0x01,0x91,0x08,0x46,0x91,0x04,0x88,0x42,0x00,0xD3,0xFE,0xE7,
0x20,0x20,0xFF,0xF7,0x1D,0xFF,0x01,0x98,0x80,0x07,0x06,0xD1,0x28,0x00,0xFF,0xF7,
0x49,0xFF,0x80,0x21,0x09,0x03,0x88,0x42,0x01,0xD1,0x20,0x46,0xFE,0xBD,0xCF,0x02,
0x38,0x00,0xFF,0xF7,0x17,0xFF,0xA9,0x0D,0x28,0x00,0xFF,0xF7,0x1D,0xFF,0x28,0x00,
0xFF,0xF7,0x29,0xFF,0xEF,0xF3,0x10,0x86,0x72,0xB6,0x5A,0x49,0x28,0x00,0xFF,0xF7,
0x2B,0xFF,0x5B,0x49,0x28,0x00,0xFF,0xF7,0x27,0xFF,0x86,0xF3,0x10,0x88,0x28,0x00,
0xFF,0xF7,0x55,0xFF,0x28,0x00,0xFF,0xF7,0x40,0xFF,0x28,0x00,0xFF,0xF7,0x2D,0xFF,
0x52,0x48,0x01,0x99,0x08,0x60,0x02,0x9E,0x76,0x1C,0xA8,0x0B,0x86,0x42,0x22,0xD2,
0x28,0x00,0xFF,0xF7,0x2C,0xFF,0x00,0x28,0x1D,0xD1,0x28,0x00,0xFF,0xF7,0x21,0xFF,
0x00,0x28,0x18,0xD1,0x28,0x00,0xFF,0xF7,0x12,0xFF,0x00,0x28,0x13,0xD1,0x28,0x00,
0xFF,0xF7,0x30,0xFF,0x00,0x28,0xE7,0xD0,0x28,0x00,0xFF,0xF7,0x30,0xFF,0x28,0x00,
0xFF,0xF7,0xFC,0xFE,0x38,0x00,0xFF,0xF7,0xDA,0xFE,0x20,0x20,0xFF,0xF7,0xCD,0xFE,
0x68,0x46,0x00,0x78,0xFE,0xBD,0x68,0x46,0x04,0x70,0xF0,0xE7,0x38,0x24,0x00,0x40,
0x4C,0x24,0x00,0x40,0xFF,0xFC,0xFF,0xFF,0xF8,0xB5,0x84,0xB0,0x16,0x00,0x00,0x24,
0x02,0x94,0x01,0x22,0x6B,0x46,0x1A,0x70,0x31,0x4D,0xA8,0x42,0x00,0xD0,0xFE,0xE7,
0x01,0x91,0x08,0x46,0x91,0x04,0x88,0x42,0x00,0xD3,0xFE,0xE7,0x20,0x20,0xFF,0xF7,
0xA7,0xFE,0x01,0x98,0x80,0x07,0x06,0xD1,0x28,0x00,0xFF,0xF7,0xD3,0xFE,0x80,0x21,
0x09,0x03,0x88,0x42,0x01,0xD1,0x20,0x46,0x44,0xE0,0x03,0x96,0xCF,0x02,0x38,0x00,
0xFF,0xF7,0xA0,0xFE,0x28,0x00,0xFF,0xF7,0xAD,0xFE,0xEF,0xF3,0x10,0x86,0x72,0xB6,
0x59,0x49,0x28,0x00,0xFF,0xF7,0xB8,0xFE,0x58,0x49,0x28,0x00,0xFF,0xF7,0xB4,0xFE,
0x86,0xF3,0x10,0x88,0x28,0x00,0xFF,0xF7,0xD0,0xFE,0x28,0x00,0xFF,0xF7,0xBD,0xFE,
0x03,0x98,0x01,0x99,0x08,0x60,0x02,0x9E,0x76,0x1C,0xA8,0x0B,0x86,0x42,0x23,0xD2,
0x28,0x00,0xFF,0xF7,0xBC,0xFE,0x00,0x28,0x1E,0xD1,0x28,0x00,0xFF,0xF7,0xB1,0xFE,
0x00,0x28,0x19,0xD1,0x28,0x00,0xFF,0xF7,0xA2,0xFE,0x00,0x28,0x14,0xD1,0x28,0x00,
0xFF,0xF7,0xB7,0xFE,0x00,0x28,0xE7,0xD0,0x28,0x00,0xFF,0xF7,0xB8,0xFE,0x28,0x00,
0xFF,0xF7,0x8C,0xFE,0x38,0x00,0xFF,0xF7,0x6A,0xFE,0x20,0x20,0xFF,0xF7,0x5D,0xFE,
0x68,0x46,0x00,0x78,0x05,0xB0,0xF0,0xBD,0x68,0x46,0x04,0x70,0xEF,0xE7,0x00,0x00,
0x00,0x10,0x00,0x40,0x96,0x96,0x96,0x96,0xEA,0xEA,0xEA,0xEA,0xCD,0xAB,0x34,0x12,
0x3C,0x3C,0x3C,0x3C,0xF7,0xB5,0x01,0x24,0x35,0x4D,0xA8,0x42,0x00,0xD0,0xFE,0xE7,
0x80,0x29,0x00,0xD3,0xFE,0xE7,0xC8,0x02,0x00,0x90,0x00,0x98,0x40,0x05,0x40,0x0D,
0x56,0xD1,0x20,0x20,0xFF,0xF7,0x34,0xFE,0xA0,0x07,0xFF,0xF7,0x3B,0xFE,0x28,0x00,
0xFF,0xF7,0x48,0xFE,0xEF,0xF3,0x10,0x86,0x72,0xB6,0x27,0x49,0x28,0x00,0xFF,0xF7,
0x53,0xFE,0x26,0x49,0x28,0x00,0xFF,0xF7,0x4F,0xFE,0x86,0xF3,0x10,0x88,0x28,0x00,
0xFF,0xF7,0x6B,0xFE,0x28,0x00,0xFF,0xF7,0x58,0xFE,0x00,0x27,0x02,0x9E,0x00,0xE0,
0x3F,0x1D,0x20,0x48,0x87,0x42,0x28,0xD8,0x00,0x24,0x28,0x00,0xFF,0xF7,0x2A,0xFE,
0x30,0x68,0x00,0x99,0x08,0x60,0x00,0x98,0x00,0x1D,0x00,0x90,0x36,0x1D,0x64,0x1C,
0xA8,0x0B,0x84,0x42,0x25,0xD2,0x28,0x00,0xFF,0xF7,0x49,0xFE,0x00,0x28,0x20,0xD1,
0x28,0x00,0xFF,0xF7,0x3E,0xFE,0x00,0x28,0x1B,0xD1,0x28,0x00,0xFF,0xF7,0x2F,0xFE,
0x00,0x28,0x16,0xD1,0x28,0x00,0xFF,0xF7,0x44,0xFE,0x00,0x28,0xE7,0xD0,0x28,0x00,
0xFF,0xF7,0x45,0xFE,0x01,0x24,0x20,0x00,0xD2,0xD1,0x28,0x00,0xFF,0xF7,0x16,0xFE,
0x80,0x20,0xC0,0x05,0xFF,0xF7,0xF3,0xFD,0x20,0x20,0xFF,0xF7,0xE6,0xFD,0x20,0x00,
0xFE,0xBD,0x00,0x24,0xEF,0xE7,0x00,0x00,0xA5,0xA5,0xA5,0xA5,0xF1,0xF1,0xF1,0xF1,
0x00,0x10,0x00,0x40,0xFF,0x07,0x00,0x00,0xF8,0xB5,0x0F,0x00,0x16,0x00,0x00,0x24,
0x25,0x00,0x21,0x00,0x6A,0x46,0x11,0x70,0x80,0x69,0x00,0x28,0x00,0xD0,0x80,0x47,
0x68,0x46,0x00,0x78,0x02,0xE0,0x80,0x21,0x09,0x01,0x6D,0x18,0xB5,0x42,0x06,0xD2,
0x79,0x19,0x41,0x48,0xFF,0xF7,0x8C,0xFE,0x01,0x00,0x01,0x29,0xF3,0xD0,0x01,0x28,
0x01,0xD1,0x20,0x00,0xF2,0xBD,0x01,0x20,0xF2,0xBD,0xF8,0xB5,0x0C,0x00,0x15,0x00,
0x1E,0x00,0x00,0x21,0x6A,0x46,0x11,0x70,0x80,0x69,0x00,0x28,0x00,0xD0,0x80,0x47,
0x31,0x00,0xAE,0x08,0xB6,0xB2,0x00,0x22,0x27,0x00,0x68,0x46,0x00,0x78,0x0D,0x00,
0x14,0x00,0x00,0xE0,0x64,0x1C,0xB4,0x42,0x09,0xD2,0x2A,0x68,0xA0,0x00,0x39,0x18,
0x2D,0x48,0xFF,0xF7,0xD9,0xFE,0x2D,0x1D,0x01,0x00,0x01,0x29,0xF2,0xD0,0x01,0x28,
0x01,0xD1,0x00,0x20,0xF2,0xBD,0x01,0x20,0xF2,0xBD,0xFE,0xB5,0x00,0x26,0x01,0x90,
0x00,0x91,0x17,0x00,0x1C,0x00,0x08,0x9D,0x00,0xE0,0x76,0x1C,0xBE,0x42,0x0D,0xD2,
0x01,0x98,0x80,0x69,0x00,0x28,0x00,0xD0,0x80,0x47,0x00,0x98,0x80,0x19,0x01,0x78,
0xA2,0x5D,0x91,0x42,0xF1,0xD0,0x28,0x60,0x01,0x20,0xFE,0xBD,0x00,0x20,0xFE,0xBD,
0x38,0xB5,0x0D,0x00,0x1C,0x00,0x80,0x69,0x00,0x28,0x00,0xD0,0x80,0x47,0x22,0x00,
0xE9,0x0A,0x15,0x48,0xFF,0xF7,0x1E,0xFF,0x01,0x28,0x01,0xD1,0x00,0x20,0x32,0xBD,
0x01,0x20,0x32,0xBD,0xF8,0xB5,0x0F,0x00,0x16,0x00,0x00,0x24,0x25,0x00,0x21,0x00,
0x6A,0x46,0x11,0x70,0x80,0x69,0x00,0x28,0x00,0xD0,0x80,0x47,0x68,0x46,0x00,0x78,
0x02,0xE0,0x80,0x21,0x89,0x00,0x6D,0x18,0xB5,0x42,0x06,0xD2,0x79,0x19,0x06,0x48,
0xFF,0xF7,0xA8,0xFD,0x01,0x00,0x01,0x29,0xF3,0xD0,0x01,0x28,0x01,0xD1,0x20,0x00,
0xF2,0xBD,0x01,0x20,0xF2,0xBD,0x00,0x00,0x00,0x10,0x00,0x40,};
/*****************************************************************************
 *  Function Definitions
 *****************************************************************************/
/**************************************************************************//**
 *
 *  \details bl_ram write data.
 *
 *  \param[in]  addr - the memory address of the data to be written in.
 *  \param[in]  size - the size of the data to be written.
 *  \param[out] buffer - the address pointer of the data to be written.
 *
 *  \return If bl_ram write data successfully returns BL_ERR_OK,
 *          otherwise returns BL_ERR_NOT_OK.
 *
 *  \retval BL_ERR_OK     - write data successfully.
 *  \retval BL_ERR_NOT_OK - write data unsuccessfully.
 *
 *  \since V2.0.0
 *
 *****************************************************************************/
bl_Return_t Ram_Write(bl_Address_t address,
                      bl_Size_t size,
                      const bl_Buffer_t *buffer)
{
    Bl_MemCpy((bl_Buffer_t *)address,buffer,size);/*lint !e511*/

    return BL_ERR_OK;
}

#define FLAG_RAM_DRIVER_ADDR   0x20007000 
bl_Return_t Ram_Init(void)
{
    //将FLAG_RAM_DRIVER_ADDR地址起始填充firmware的内容
    Bl_MemCpy((bl_Buffer_t *)FLAG_RAM_DRIVER_ADDR,(const bl_Buffer_t *)firmware,sizeof(firmware));/*lint !e511*/
    return BL_ERR_OK;
}

/**************************************************************************//**
 *
 *  \details bl_ram read data.
 *
 *  \param[in]  addr - the memory address of the data to be read from.
 *  \param[in]  size - the size of the data to be read.
 *  \param[out] buffer - the saving address pointer of the data to be read.
 *
 *  \return If bl_ram reads data successfully returns BL_ERR_OK,
 *          otherwise returns BL_ERR_NOT_OK.
 *
 *  \retval BL_ERR_OK     - read data successfully.
 *  \retval BL_ERR_NOT_OK - read data unsuccessfully.
 *
 *  \since V2.0.0
 *
 *****************************************************************************/
bl_Return_t Ram_Read(bl_Address_t address,
                     bl_Size_t size,
                     bl_Buffer_t *buffer)
{
    Bl_MemCpy(buffer,(const bl_Buffer_t *)address,size);/*lint !e511*/

    return BL_ERR_OK;
}




